home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-19
/
hpgl2scr.zip
/
HPGL2SCR.DOC
< prev
next >
Wrap
Text File
|
1991-09-19
|
5KB
|
121 lines
HPGL TO AUTOCAD SCRIPT FILE CONVERSION PROGRAM
Recently, my lab at work switched from LogiCadd to AutoCAD. What a
difference! The only problem was that we needed to redo some old drawings
for a new paper. We couldn't find a program that would convert the files
directly, so we were left with the choice of either re-entering the
drawings by hand or writing our own conversion program.
LogiCadd drawing files have some proprietary format, as do AutoCAD, and I
could find virtually no documentation on either. LogiCadd will, however,
produce files of HPGL plotter commands which are (almost) pure ASCII text.
AutoCAD cannot read HPGL, but it does have a script language which can
contain drawing commands, again in an ASCII file.
This program, HPGL2SCR, converts some common HPGL commands into AutoCAD
script language commands. The conversions are as follows:
HPGL Command Function AutoCAD Script Command
IP (P1X,P1Y(,P2X,P2Y)); Set locations for the *
scaling points P1 and
P2.
LB (YOUR TEXT HERE)^C Plot labels, titles, TEXT LASTX,LASTY
or other text. [YOUR TEXT HERE] \n
PA X,Y(,...); Move the pen to one LINE LASTX,LASTY X,Y (...)
or more sets of
points (X,Y).
PD (X,Y,...); Put the pen to the none
paper. Optionally
move to (X,Y);
PU (X,Y,...); Lift the pen from the none
paper. Optionally
move to (X,Y);
SC (U1X,U2X,U1Y,U2Y); Establish user-unit *
coordinate system
between P1 and P2.
SR (width,height); Change size of chars STYLE TXT [HEIGHT] [ASPECT]
plotted with LB as a
percentage of distance
between P1 and P2.
1. Optional parameters are shown in parentheses. If no parameters are
included, default values are used.
2. IP and SC combine to determine the relationship between user units and
AutoCAD units. Default values for the IP instruction are P1X = 250,
P1Y = 279, P2X = 10250, and P2Y = 7479. For SC, it's U1X = P1X,
U2X = P2X, U1Y = P1Y, and U2Y = P2Y. If the user coordinates are AX
and AY, the AutoCAD coordinates are determined by the equations
X = ((AX - U1X) * (P2X - P1X) / (U2X - U1X) + P1X) / 1000
Y = ((AY - U1Y) * (P2Y - P1Y) / (U2Y - U1Y) + P1Y) / 1000
Trust me.
Page 1
3. The SR instruction calculates HEIGHT and ASPECT as
HEIGHT = height * (P2Y - P1Y) / 100000
ASPECT = width / height * (P2X - P1X) / (P2Y - P1Y)
Default values are height = 0.75 and width = 1.5, this time I really
mean it.
4. Since the argument for the LB command may inadvertently contain other
valid HPGL commands, it is detected and processed first.
The input file must have the extension ".PLT", although you must leave the
extension off when prompted for the input file name. The input file name
may also be entered on the command line. The output file will have the
same name, with the extension ".SCR". To use this file, run AutoCAD and
choose to work on a new drawing. When the drawing screen appears, type
"SCRIPT ", followed by the name of the script file. Then just sit back and
watch! The screen will automatically redraw when the input is complete.
You can then save the file just as with any other AutoCAD drawing.
Any HPGL command file produced by any program can be used as input. Some
Hewlett-Packard instruments will produce screen dumps in HPGL format. If
you can capture this into a file, you can use it. While this program
clearly will not handle all possible HPGL commands, it is sufficient for
most purposes. If it does not recognize a command, it ignores it. Even if
you have to clean up the AutoCAD drawing a bit, this method is faster than
redoing the drawing from the start.
With documentation on other drawing command languages, it seems like it
would be easy to modify this program to say, convert HPGL to GERBER or vice
versa. There was a thread concerning GERBER photoplotter file format
recently in sci.electronics, for example.
A sample file called PROHOOPS.PLT is included. Have Fun!
William D. "Dev" Palmer, Ph.D.
Dev Palmer Electronics Consulting
1313 Vickers Avenue
Durham, NC 27707
wdp@ee.egr.duke.edu
Page 2